package thread;

public class demo3 {
    private static Object locker = new Object();

    public static void main(String[] args) {
        Thread t1 = new Thread(() ->{
           synchronized (locker){
               System.out.println("等待前");
               try {
                   locker.wait();
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               System.out.println("等待后");
           }
        });
        Thread t2 = new Thread(() ->{
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (locker){
                System.out.println("进行通知");
                locker.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
